package com.house.tgroup.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.house.tgroup.entity.DiscontEntity;
import com.house.tgroup.service.DiscontService;
import com.house.common.utils.PageUtils;
import com.house.common.utils.R;



/**
 * 
 *
 * @author wzh
 * @email sunlightcs@gmail.com
 * @date 2022-04-27 17:35:02
 */
@RestController
@RequestMapping("tgroup/discont")
public class DiscontController {
    @Autowired
    private DiscontService discontService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = discontService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{discontId}")
    public R info(@PathVariable("discontId") Integer discontId){
		DiscontEntity discont = discontService.getById(discontId);
        return R.ok().put("discont", discont);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody DiscontEntity discont){
		discontService.save(discont);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody DiscontEntity discont){
		discontService.updateById(discont);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] discontIds){
		discontService.removeByIds(Arrays.asList(discontIds));

        return R.ok();
    }

}
